using System.Collections;
using System.Collections.Generic;
using UnityEngine;

using LitTools;
namespace LitToolsTest
{
    public class CubeMoveState : IState
    {
        public float maxSpeed = 5;
        public float moveSpeed = 0;
        public GameObject cube;
        private Vector3 dir;
        public void OnEnter(StateMechine mechine)
        {
            moveSpeed = 0;
            if (Input.GetKey(KeyCode.W))
                dir = Vector3.up;
            else if (Input.GetKey(KeyCode.S))
                dir = Vector3.down;
        }

        public void OnExit(StateMechine mechine)
        {

        }

        public void OnUpdate(StateMechine mechine)
        {
            if (moveSpeed < maxSpeed)
                moveSpeed += Time.deltaTime;

            cube.transform.Translate(Time.deltaTime * moveSpeed * dir);
        }
    }

    public class CubeIdleState : IState
    {
        public GameObject cube;
        public float maxScale = 1.1f;
        private float curScale = 1;
        public void OnEnter(StateMechine mechine)
        {
            cube.transform.localScale = Vector3.one;
            curScale = 1;
        }

        public void OnExit(StateMechine mechine)
        {
            cube.transform.localScale = Vector3.one;
        }

        public void OnUpdate(StateMechine mechine)
        {
            if (curScale < maxScale)
                curScale += Time.deltaTime;
            else
                curScale = 1;
            cube.transform.localScale = new Vector3(curScale, curScale, curScale);
        }
    }
}
